YT New Video Upload

工作流概述

这是一个包含14个节点的复杂工作流,主要用于自动化处理各种任务。

工作流源代码

下载
{
  "id": "gIZpJgLpUgdoNNDZ",
  "meta": {
    "instanceId": "9ee1559971f36d9785fb97b48d76ed3a8ac302ff00dd93d8b7301e3feab97aed",
    "templateCredsSetupCompleted": true
  },
  "name": "YT New Video Upload",
  "tags": [],
  "nodes": [
    {
      "id": "add1cd70-4bf4-42f5-87d9-68fa31af7f56",
      "name": "Download New Video",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -140,
        220
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "8GbkH30Del5g4Kbq",
          "name": "Jim Privat"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1308e94d-1c68-4fae-9d94-ba6248947581",
      "name": "New Video?",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -360,
        220
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": "1EOMCzVDif4XnqCloYvhBNZdx7gyRNpTR"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "8GbkH30Del5g4Kbq",
          "name": "Jim Privat"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dfb073fc-4365-4669-a17c-73407a14a655",
      "name": "Create Description",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1000,
        180
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-nano",
          "cachedResultName": "GPT-4.1-NANO"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a professional copywriter.  
You receive the transcript of an economics-related video and create a detailed but concise summary (with paragraphs) about its content.  

Write a detailed summary (with paragraphs) about the content of the podcast.  

Your output will be used for the YouTube video description. Start with something like: \"In this video...\" or \"In this episode...\".  
Write from my perspective, using phrases like \"my opinion\" or \"in my view,\" in the first person, but never phrases like \"In this episode, I learn...\" or similar, as I always explain or discuss the content. YOU NEVER WRITE THINGS LIKE \"THE SPEAKER SAYS\"! Always from my position.  

Important: Use clear and assertive statements as formulated in the transcript. Avoid neutral or uncertain phrases like \"it could,\" \"I assume that,\" \"possibly,\" or similar. The statements should be confident and definitive to powerfully convey the podcast’s content.  
Include a few (2-4) emojis where appropriate.  
End the post with 2-5 relevant hashtags. The hashtags should be broad, like #economics #money #gold, or similar, depending on what fits."
            },
            {
              "content": "=Here is the transcript:

{{ $json.transcript }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "8VZkrnuHUTXNwnlP",
          "name": "Midgard#1"
        }
      },
      "typeVersion": 1.7
    },
    {
      "id": "25ba2d0b-3a7a-49d6-acfa-6e7fa2b98e86",
      "name": "2.5FlashPrev",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1340,
        180
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-04-17"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "2Y7XbTPZaxPz6Vhw",
          "name": "Jim Privat"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "23141199-5df7-47d0-8d0e-f5b3a7fe7668",
      "name": "YT Tags",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1300,
        -20
      ],
      "parameters": {
        "text": "=Now follows the actual topic/transcript. Give me the YouTube tags for it:

{{ $('Adjust Transcript Format').item.json.transcript }}",
        "options": {
          "systemMessage": "This video is about the future gold price and how it affects the returns of high-performing assets like stocks and bonds in their adjusted returns.

Expected output:
Gold price, future gold price, gold investments, asset returns, stocks and bonds, investment returns, adjusted returns, gold market, financial markets, gold price forecast, economic trends, investing in gold, stock market analysis, bond market, investment strategies, inflation and gold, gold vs. stocks, financial analysis, precious metals, portfolio management, market outlook, investment tips"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "c3ff8e2e-7ce6-4538-baea-91a375b98dcb",
      "name": "Get Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        500,
        220
      ],
      "parameters": {
        "url": "=https://api.apify.com/v2/acts/pintostudio~youtube-transcript-scraper/run-sync-get-dataset-items",
        "method": "POST",
        "options": {},
        "jsonBody": "={
  \"videoUrl\": \"https://www.youtube.com/watch?v={{ $json.id }}\"
}",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{$json.token}}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "6a03cbf3-5718-4db8-b9cf-31d6d93f73e7",
      "name": "Adjust Transcript Format",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        220
      ],
      "parameters": {
        "jsCode": "const items = $input.all();

const transcriptStrings = items.flatMap(item => {
  const dataArray = item.json.data;

  if (!dataArray || !Array.isArray(dataArray)) {
    return [];
  }

  const segmentTexts = dataArray.map(segment => {
      if (segment && typeof segment.text === 'string') {
          return segment.text;
      } else {
          return '';
      }
  });

  return segmentTexts;
});

const transcript = transcriptStrings.join(' ');

return [
  {
    json: {
      transcript: transcript,
    },
  },
];"
      },
      "typeVersion": 2
    },
    {
      "id": "c6e0bf83-6eaa-41be-9ea1-0dba4cace444",
      "name": "Update Video's Metadata",
      "type": "n8n-nodes-base.youTube",
      "onError": "continueErrorOutput",
      "position": [
        2160,
        240
      ],
      "parameters": {
        "title": "={{ $('YT Title').item.json.title }}",
        "videoId": "={{ $('Upload Video to Youtube').item.json.uploadId }}",
        "resource": "video",
        "operation": "update",
        "categoryId": "25",
        "regionCode": "DE",
        "updateFields": {
          "tags": "={{ $('YT Tags').item.json.message.content }}",
          "description": "={{ $('Create Description').first().json.message.content }}

Diese textbasierte Zusammenfassung des Videos wurde automatisch mit dem KI-Modell gpt-4.1-nano erstellt.]
"
        }
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "jKf1Vc4ZycKxf0im",
          "name": "YouTube Jim Privat"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "813fc8fc-ed3c-4cd7-8aa5-4c4084fd4e0d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        160
      ],
      "parameters": {
        "color": 4,
        "width": 700,
        "height": 240,
        "content": "# Upload New Video to Youtube 🎥⬆️"
      },
      "typeVersion": 1
    },
    {
      "id": "0fb360ba-f843-4820-b05d-3149d7516526",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -100
      ],
      "parameters": {
        "color": 4,
        "width": 2660,
        "height": 500,
        "content": "# Get Transcript for Context and Generate Metadata from It 📝🔍"
      },
      "typeVersion": 1
    },
    {
      "id": "bb494b9e-a707-492a-b88a-83fce01a742f",
      "name": "YT Title",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1720,
        -20
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-nano",
          "cachedResultName": "GPT-4.1-NANO"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a professional copywriter for SEO-optimized YouTube titles."
            },
            {
              "content": "=Write me a suitable SEO YouTube title for the transcript of the following video transcript. Only the title, nothing else. Max 100 characters, so keep it short."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "8VZkrnuHUTXNwnlP",
          "name": "Midgard#1"
        }
      },
      "typeVersion": 1.7
    },
    {
      "id": "a82d27b7-967e-48f8-8ead-a184872a7abc",
      "name": "Delete File from Upload Folder (Optional)",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2460,
        -20
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Download New Video').item.json.id }}"
        },
        "options": {},
        "operation": "deleteFile"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "8GbkH30Del5g4Kbq",
          "name": "GDRIVE ACCOUNT P"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4cff725b-cff0-45e0-9cab-24c2f233c94e",
      "name": "Upload Video to Youtube",
      "type": "n8n-nodes-base.youTube",
      "position": [
        140,
        220
      ],
      "parameters": {
        "title": "adadada",
        "options": {
          "privacyStatus": "private",
          "selfDeclaredMadeForKids": false
        },
        "resource": "video",
        "operation": "upload",
        "categoryId": "25",
        "regionCode": "DE"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "jKf1Vc4ZycKxf0im",
          "name": "YouTube Jim Privat"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "691fda3c-736c-4d6e-b4f3-8db68a581c79",
      "name": "ApifyToken",
      "type": "n8n-nodes-base.set",
      "position": [
        320,
        220
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2eb41a6f-d0ef-4ca2-be47-f93b1d5c1edb",
              "name": "token",
              "type": "string",
              "value": "YOURTOKENHERE"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3a879f43-d8a6-4a87-a233-bafeb296d21a",
  "connections": {
    "YT Tags": {
      "main": [
        [
          {
            "node": "YT Title",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YT Title": {
      "main": [
        [
          {
            "node": "Update Video's Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ApifyToken": {
      "main": [
        [
          {
            "node": "Get Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Video?": {
      "main": [
        [
          {
            "node": "Download New Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2.5FlashPrev": {
      "ai_languageModel": [
        [
          {
            "node": "YT Tags",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Transcript": {
      "main": [
        [
          {
            "node": "Adjust Transcript Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Description": {
      "main": [
        [
          {
            "node": "YT Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download New Video": {
      "main": [
        [
          {
            "node": "Upload Video to Youtube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Video's Metadata": {
      "main": [
        [
          {
            "node": "Delete File from Upload Folder (Optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video to Youtube": {
      "main": [
        [
          {
            "node": "ApifyToken",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Adjust Transcript Format": {
      "main": [
        [
          {
            "node": "Create Description",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

  • 自动检测新邮件
  • AI智能内容分析
  • 自定义分类规则
  • 批量处理能力
  • 详细的处理日志

技术分析

节点类型及作用

  • Googledrive
  • Googledrivetrigger
  • @N8N/N8N Nodes Langchain.Openai
  • @N8N/N8N Nodes Langchain.Lmchatgooglegemini
  • @N8N/N8N Nodes Langchain.Agent

复杂度评估

配置难度:
★★★★☆
维护难度:
★★☆☆☆
扩展性:
★★★★☆

实施指南

前置条件

  • 有效的Gmail账户
  • n8n平台访问权限
  • Google API凭证
  • AI分类服务订阅

配置步骤

  1. 在n8n中导入工作流JSON文件
  2. 配置Gmail节点的认证信息
  3. 设置AI分类器的API密钥
  4. 自定义分类规则和标签映射
  5. 测试工作流执行
  6. 配置定时触发器(可选)

关键参数

参数名称 默认值 说明
maxEmails 50 单次处理的最大邮件数量
confidenceThreshold 0.8 分类置信度阈值
autoLabel true 是否自动添加标签

最佳实践

优化建议

  • 定期更新AI分类模型以提高准确性
  • 根据邮件量调整处理批次大小
  • 设置合理的分类置信度阈值
  • 定期清理过期的分类规则

安全注意事项

  • 妥善保管API密钥和认证信息
  • 限制工作流的访问权限
  • 定期审查处理日志
  • 启用双因素认证保护Gmail账户

性能优化

  • 使用增量处理减少重复工作
  • 缓存频繁访问的数据
  • 并行处理多个邮件分类任务
  • 监控系统资源使用情况

故障排除

常见问题

邮件未被正确分类

检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。

Gmail认证失败

确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。

调试技巧

  • 启用详细日志记录查看每个步骤的执行情况
  • 使用测试邮件验证分类逻辑
  • 检查网络连接和API服务状态
  • 逐步执行工作流定位问题节点

错误处理

工作流包含以下错误处理机制:

  • 网络超时自动重试(最多3次)
  • API错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作